﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            MyListElement mle1 = new MyListElement();
            Random rd = new Random();
            MyList A = new MyList();
            Stopwatch sw = new Stopwatch();
            sw.Restart();
            for (int i = 0; i < 1000000; i++)
            {
               A.Add( rd.Next(0, 9));

            } mle1 = A.first;
            for (int i = 0; i < 100; i++)
            {
                mle1.next;
            }
            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);


            Console.ReadLine();
        }
    }

    class MyList
    {
        public MyListElement first;
        public MyListElement last;
        public void Add(int a)
        {
            MyListElement mle = new MyListElement();
            mle.data = a;
            if (first == null && last == null)
            {
                first = mle;
                last = mle;
                first.next = last;
            } else
        
                {
                    last.next = mle;
                    last = mle;
                    
                } 
            
        }

    }
    class MyListElement
    {
        public MyListElement next;
        public int data;
    }
}
